feat(ci): add priority label to preempt runners for high-priority sweeps#1726
Open
cquil11 wants to merge 1 commit into
Open
feat(ci): add priority label to preempt runners for high-priority sweeps#1726cquil11 wants to merge 1 commit into
cquil11 wants to merge 1 commit into
Conversation
When an org member adds 'priority' alongside a sweep label, setup cancels every other in-progress or queued run with jobs on the sweep's target runners (resolved through each runner's full label set, since SKU fleets share nodes across labels) and records them in the preempted-runs artifact. A restore-preempted job at the end re-runs each victim's failed jobs via gh run rerun --failed. Preemption is run-granular: GitHub has no per-job cancel API.
Comment on lines
+830
to
+855
| needs: [setup, collect-results, collect-evals] | ||
| if: >- | ||
| always() && | ||
| github.event_name == 'pull_request' && | ||
| contains(github.event.pull_request.labels.*.name, 'priority') && | ||
| needs.setup.result == 'success' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download preempted runs artifact | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: preempted-runs | ||
|
|
||
| - name: Re-run failed jobs of preempted runs | ||
| env: | ||
| GH_TOKEN: ${{ secrets.REPO_PAT || github.token }} | ||
| run: | | ||
| count=$(jq 'length' preempted_runs.json) | ||
| echo "Restoring ${count} preempted run(s)" | ||
| jq -r '.[].run_id' preempted_runs.json | while read -r id; do | ||
| if gh run rerun "$id" --failed --repo "${{ github.repository }}"; then | ||
| echo "Re-ran failed jobs of run ${id}" | ||
| else | ||
| echo "::warning::Could not re-run failed jobs of run ${id}; restore manually with: gh run rerun ${id} --failed --repo ${{ github.repository }}" | ||
| fi | ||
| done |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6a11a53. Configure here.
| always() && | ||
| github.event_name == 'pull_request' && | ||
| contains(github.event.pull_request.labels.*.name, 'priority') && | ||
| needs.setup.result == 'success' |
There was a problem hiding this comment.
Preempt without guaranteed restore
Medium Severity
Preemption and artifact upload live in setup, but restore-preempted runs only when needs.setup.result == 'success'. If Upload preempted runs artifact fails after runs were cancelled, the setup job fails and restore never runs, though victims were already preempted.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6a11a53. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds a
prioritymodifier label for run-sweep PRs (combine with any sweep label), per the Slack discussion — reserved for day-0-style launches that need the fleet now.What it does
setup): derives target runner labels from the PR's own search space, cancels every other in-progress or queued run with jobs on those runners, waits for them to release, and uploads the victim list as thepreempted-runsartifact. Matching goes through each runner's full label set (utils/preempt_runners.py), so e.g. ab200priority sweep preempts ab200-multinodejob occupying a shared node.restore-preempted,if: always()): re-runs each victim's failed jobs withgh run rerun --failedonce the priority sweep finishes.When it's useful
Caveats
restore-preemptedfires, restore manually from thepreempted-runsartifact.rerun --failedon cancelled jobs should be verified once in anger; fallback is per-jobPOST /actions/jobs/{id}/rerun.Selection logic is covered by
utils/test_preempt_runners.py(11 tests). Theprioritylabel has been created in the repo.Note
Medium Risk
Cancels arbitrary in-flight CI runs across the repo when misused; mitigated by org-only label auth and documented restore path, but collateral run cancellation is inherent.
Overview
Adds a
prioritymodifier label for PR sweeps (used together with an existing sweep label).run-sweep.ymltreatsprioritylike other sweep labels for concurrency and re-triggers, then insetupverifies the label was added by an org member (otherwise removes it and fails), cancels other in-progress/queued runs whose jobs compete for the sweep’s runner labels via newutils/preempt_runners.py, uploads victim run IDs aspreempted-runs, and after the sweeprestore-preemptedre-queues victims withgh run rerun --failed.Preemption is whole-run (GitHub has no per-job cancel); matching uses each runner’s full label set so shared nodes (e.g.
b200vsb200-multinode) are handled correctly.AGENTS.mddocuments usage and caveats;utils/test_preempt_runners.pycovers selection logic.Reviewed by Cursor Bugbot for commit 6a11a53. Bugbot is set up for automated code reviews on this repo. Configure here.